package com.alinesno.cloud.initializr.starter.gateway.rest;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.alinesno.cloud.common.core.constants.SpringInstanceScope;
import com.alinesno.cloud.common.facade.pageable.DatatablesPageBean;
import com.alinesno.cloud.initializr.starter.entity.InitializrJavaVersionEntity;
import com.alinesno.cloud.initializr.starter.gateway.aop.DataFilter;
import com.alinesno.cloud.initializr.starter.service.IInitializrJavaVersionService;
import com.alinesno.cloud.rest.gateway.adapter.page.TableDataInfo;
import com.alinesno.cloud.rest.gateway.adapter.plugins.TranslateCode;
import com.alinesno.cloud.rest.gateway.adapter.rest.BaseRestAdapter;

/**
 * <p> 前端控制器 </p>
 *
 * @author ${author}
 * @since 2020-11-20 10:06:08
 */
@RestController
@Scope(SpringInstanceScope.PROTOTYPE)
@RequestMapping("com/alinesno/cloud/initializr/initializrJavaVersion")
public class InitializrJavaVersionRest extends BaseRestAdapter<InitializrJavaVersionEntity, IInitializrJavaVersionService> {

	//日志记录
	private static final Logger log = LoggerFactory.getLogger(InitializrJavaVersionRest.class);

	@Autowired
	private IInitializrJavaVersionService initializrJavaVersionService; 

    @DataFilter
	@TranslateCode(value="[{hasStatus:has_status}]")
	@ResponseBody
	@PostMapping("/datatables")
    public TableDataInfo datatables(HttpServletRequest request , Model model ,  DatatablesPageBean page){
		log.debug("page = {}" , ToStringBuilder.reflectionToString(page));
		return this.toPage(model, this.getFeign() , page) ;
    }


	@Override
	public IInitializrJavaVersionService getFeign() {
		return this.initializrJavaVersionService;
	}

}


























